package com.bifang.module.file.gateway.controller;

import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.module.file.common.vo.FileInfoVO;
import com.bifang.module.file.common.vo.FileKeyVO;
import com.bifang.module.file.common.vo.FileMd5VO;
import com.bifang.module.file.common.vo.FileMetadataVO;
import com.bifang.module.file.core.biz.FileManagerIntegration;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "文件管理", description = "文件管理")
public class FileManagerController {
    @Autowired
    FileManagerIntegration fileManagerIntegration;

    @Operation(summary = "获取文件信息列表",description = "获取文件信息列表")
    @PostMapping(value = "/fileManager0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<FileInfoVO>> getFileInfoList(@RequestBody FileInfoVO fileInfoVO){
        return AppResponse.successData(fileManagerIntegration.getFileInfoList(fileInfoVO));
    }


    @Operation(summary = "获取文件基础信息详情",description = "获取文件基础信息详情")
    @PostMapping(value = "/fileManager0002", produces = "application/json;charset=UTF-8")
    public AppResponse<FileInfoVO> getFileInfoDetail(@RequestBody FileKeyVO fileKeyVO){
        return AppResponse.successData(fileManagerIntegration.getFileInfoDetail(fileKeyVO));
    }

    @Operation(summary = "根据Md5获取文件信息",description = "根据Md5获取文件信息")
    @PostMapping(value = "/fileManager0003", produces = "application/json;charset=UTF-8")
    public AppResponse<List<FileInfoVO>> getFileInfoDetail(@RequestBody FileMd5VO fileMd5VO){
        return AppResponse.successData(fileManagerIntegration.getFileInfoByMd5(fileMd5VO));
    }

    @Operation(summary = "新增文件基础信息",description = "新增文件基础信息")
    @PostMapping(value = "/fileManager0004", produces = "application/json;charset=UTF-8")
    public AppResponse addFileInfo(@RequestBody FileInfoVO fileInfoVO){
        fileManagerIntegration.addFileInfo(fileInfoVO);
        return AppResponse.success();
    }

    @Operation(summary = "修改文件基础信息",description = "修改文件基础信息")
    @PostMapping(value = "/fileManager0005", produces = "application/json;charset=UTF-8")
    public AppResponse updateFileInfo(@RequestBody FileInfoVO fileInfoVO){
        fileManagerIntegration.updateFileInfo(fileInfoVO);
        return AppResponse.success();
    }

    @Operation(summary = "删除基础信息",description = "删除基础信息")
    @PostMapping(value = "/fileManager0006", produces = "application/json;charset=UTF-8")
    public AppResponse deleteFileInfo(@RequestBody FileKeyVO fileKeyVO){
        fileManagerIntegration.deleteFileInfo(fileKeyVO);
        return AppResponse.success();
    }


    @Operation(summary = "获取文件元数据信息列表",description = "获取文件元数据信息列表")
    @PostMapping(value = "/fileManager0007", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<FileMetadataVO>> getFileMetadataList(@RequestBody FileMetadataVO fileMetadataVO){
        return AppResponse.successData(fileManagerIntegration.getFileMetadataList(fileMetadataVO));
    }

    @Operation(summary = "修改文件元数据信息",description = "修改文件元数据信息")
    @PostMapping(value = "/fileManager0008", produces = "application/json;charset=UTF-8")
    public AppResponse<FileMetadataVO> updateMetaData(@RequestBody FileMetadataVO fileMetadataVO){
        return AppResponse.successData(fileManagerIntegration.updateMetaData(fileMetadataVO));
    }


    @Operation(summary = "获取服务大厅文件信息列表",description = "获取服务大厅文件信息列表")
    @PostMapping(value = "/fileManager0009", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<FileInfoVO>> getFileHomeInfo(@RequestBody FileInfoVO fileInfoVO){
        return AppResponse.successData(fileManagerIntegration.getFileHomeInfo(fileInfoVO));
    }

    @Operation(summary = "获取授权文件信息列表",description = "获取授权文件信息列表")
    @PostMapping(value = "/fileManager0010", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<FileInfoVO>> getEmpowerFile(@RequestBody FileInfoVO fileInfoVO){
        return AppResponse.successData(fileManagerIntegration.getEmpowerFile(fileInfoVO));
    }

}
